import { Injectable, NestInterceptor, CallHandler } from '@nestjs/common';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { v4 as uuidv4 } from 'uuid';

@Injectable()
export class RequestInterceptor implements NestInterceptor {
	intercept(context: any, next: CallHandler): Observable<any> {
		const request = context.switchToHttp().getRequest() as IRequest
		request.trackId=uuidv4()
		request.requestTime = Date.now();

		return next
		.handle()
		.pipe(
			tap((data) => {

			}),
		);
	}
}
